package com.zzf.concurrent.example.api;

import lombok.extern.slf4j.Slf4j;

/**
 * @author GaoFeng2017
 * @date 2019/8/4 23:48
 */
@Slf4j
public class ThreadConstructorExample {
    public static void main(String[] args) {
        Thread t1 = new Thread(new Runnable() {
            @Override
            public void run() {
                log.info("t1 ThreadGroup is {}", Thread.currentThread().getThreadGroup());
                try {
                    Thread.sleep(300);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
        });

        t1.start();
        ThreadGroup threadGroup = Thread.currentThread().getThreadGroup();
        log.info("main ThreadGroup is {}", threadGroup);

        int activeCount = threadGroup.activeCount();
        log.info("threadGroup activeCount is {} ", activeCount);
        Thread[] list = new Thread[activeCount];
        log.info("threadGroup enumerate is {}, {}", threadGroup.enumerate(list), list);

    }
}
